package net.zjitc.interfaces.uses;

import org.omg.CORBA.PUBLIC_MEMBER;

/**
 * @Author admin
 * @Date 2019/3/26 13:47
 */
public class Computer {
    USB[] usbs;

    public Computer(){
        usbs=new USB[3];
    }

    public void add(USB usb){
        for (int i = 0; i <usbs.length ; i++) {
            if (usbs[i]==null){
                usbs[i]=usb;
            }
        }
    }

    public void powerOn(){
        for (int i = 0; i <usbs.length ; i++) {
            if (usbs[i]!=null){
                usbs[i].turnOn();
            }
        }
        System.out.println("计算机开机成功！");
    }

    public void powerOff(){
        for (int i = 0; i <usbs.length ; i++) {
            if (usbs[i]==null){
                usbs[i].turnOff();
            }
        }
        System.out.println("计算机关机成功！");
    }
}
